package com.cnd.scm.rabbitmq.common;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @version V1.0
 * @ClassName: MessageWithTime
 * @Description:
 * @author: 李启联
 * @date: 2021-02-24 11:04
 * @Copyright: Copyright (c), 2021
 */
public class MessageLog implements Serializable {
    //消息ID唯一标识
    private String messageId;

    //消息内容
    private Object message;

    //消息重试发送次数
    private Integer retryNum = 0;

    //交换机
    private String exchange;

    //路由键
    private String routingKey ;

    //状态: 0投递中 1投递成功 2投递失败 3已消费
    private Integer status = 0;

    //创建时间
    private LocalDateTime createTime;

    //更新时间
    private LocalDateTime updateTime;

    public String getMessageId() {
        return messageId;
    }

    public void setMessageId(String messageId) {
        this.messageId = messageId;
    }

    public Object getMessage() {
        return message;
    }

    public void setMessage(Object message) {
        this.message = message;
    }

    public Integer getRetryNum() {
        return retryNum;
    }

    public void setRetryNum(Integer retryNum) {
        this.retryNum = retryNum;
    }

    public String getExchange() {
        return exchange;
    }

    public void setExchange(String exchange) {
        this.exchange = exchange;
    }

    public String getRoutingKey() {
        return routingKey;
    }

    public void setRoutingKey(String routingKey) {
        this.routingKey = routingKey;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    public MessageLog(String messageId, Object message, Integer retryNum, String exchange, String routingKey) {
        this.messageId = messageId;
        this.message = message;
        this.retryNum = retryNum;
        this.exchange = exchange;
        this.routingKey = routingKey;
        this.status = 0;
        this.createTime = LocalDateTime.now();
        this.updateTime = LocalDateTime.now();
    }

    public MessageLog(String messageId, Object message, Integer retryNum, String exchange, String routingKey, Integer status, LocalDateTime createTime, LocalDateTime updateTime) {
        this.messageId = messageId;
        this.message = message;
        this.retryNum = retryNum;
        this.exchange = exchange;
        this.routingKey = routingKey;
        this.status = status;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }

    public MessageLog() {
    }

    @Override
    public String toString() {
        return "MessageLog{" +
                "messageId='" + messageId + '\'' +
                ", message=" + message +
                ", retryNum=" + retryNum +
                ", exchange='" + exchange + '\'' +
                ", routingKey='" + routingKey + '\'' +
                ", status=" + status +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                '}';
    }
}